﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Caching;
using KL.Store.Core.Domain;
using TN.Data;
using System.Web;
namespace KL.Store.Data
{
    public class dbBanner
    {
        #region GetList

        public static IList<Banner> GetList()
        {

            var cacheKey = "Banner";
            if (HttpRuntime.Cache[cacheKey] != null)
            {
                return HttpRuntime.Cache[cacheKey] as IList<Banner>;
            }
            IList<Banner> objectList = new List<Banner>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_Banner_List", objectList);
            HttpRuntime.Cache.Add(cacheKey, objectList, null, DateTime.UtcNow.AddDays(1), Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null);
            return objectList;
        }

        #endregion

        #region GetAll

        public static IList<Banner> GetAll()
        {
            IList<Banner> objectList = new List<Banner>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_Banner_GetAll", objectList);

            return objectList;
        }

        #endregion

        #region Get

        public static Banner Get(int BannerId)
        {
            IList<Banner> objectList = new List<Banner>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_Banner_Get", objectList, new object[] { BannerId });

            return objectList.FirstOrDefault();
        }

        #endregion

        #region Set

        public static int Set(Banner banner)
        {
            int result = (int)SqlHelper.ExecuteScalar(dbParameters.dsnStore, "SPR_ESTORE_Banner_Set", new object[] { banner.BannerID, banner.Name, banner.Aciklama, banner.IsActive, banner.ListOrder, banner.Url, banner.PublishDate, banner.EndDate, banner.Pozisyon, banner.Html });
            return result;
        }

        #endregion

        #region Delete

        public static int Delete(int BannerId)
        {
            int result = (int)SqlHelper.ExecuteScalar(dbParameters.dsnStore, "SPR_ESTORE_Banner_Delete", new object[] { BannerId });
            return result;
        }

        #endregion

    }
}
